package br.com.toscano.contpedido.view;

import javax.inject.Inject;
import br.gov.frameworkdemoiselle.annotation.PreviousView;
import br.gov.frameworkdemoiselle.stereotype.ViewController;
import br.gov.frameworkdemoiselle.template.AbstractEditPageBean;
import br.gov.frameworkdemoiselle.transaction.Transactional;
import br.com.toscano.contpedido.business.StatusPedidoBC;
import br.com.toscano.contpedido.domain.StatusPedido;

@ViewController
@PreviousView("./statusPedido_list.jsf")
public class StatusPedidoEditMB extends AbstractEditPageBean<StatusPedido, Long> {

	private static final long serialVersionUID = 1L;

	@Inject
	private StatusPedidoBC statusPedidoBC;
	
	@Override
	@Transactional
	public String delete() {
		this.statusPedidoBC.delete(getId());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String insert() {
		this.statusPedidoBC.insert(getBean());
		return getPreviousView();
	}
	
	@Override
	@Transactional
	public String update() {
		this.statusPedidoBC.update(getBean());
		return getPreviousView();
	}
	
	@Override
	protected StatusPedido handleLoad(Long id) {
		setBean(this.statusPedidoBC.load(id));
		
		return this.getBean();
	}

}